var $x = window.$x || {};

(function(){

    $x.isNumber = o => { return typeof o === "number"; };
    $x.isString = o => { return typeof o === "string"; };
    $x.isArray = o => { return typeof o === "object" && Array.isArray(o); };
    $x.isNull = o => { return o == null || o == "" || o == undefined;};
    $x.isFunc = o => { return typeof o == "function"; };
    $x.isObject = (o, x) => { return !$x.isNull(o) && !$x.isArray(o) && ($x.isNull(x) && typeof o == "object") || (!$x.isNull(x) && o.constructor == x);};

    
    function defineReactive(obj, key, val) {
        Object.defineProperty(obj, key, {
            get: function () {
                return val;
            },
            set: function (newVal) {
                if (newVal === val) {
                    return;
                }
                val = newVal;                        
            }
        });
    }

    var $d_prototype = {};
    var $d = function(name, props){
	var self = this;
	if(name == "#text"){
	    self.$doc = document.createTextNode(props);
	} else {
	    self.$doc = document.createElement(name);
	    Object.keys(props).forEach(function(key) {
		defineReactive($d_prototype, key, props[key]);
	    });
	}
    };
    
    $d.prototype = $d_prototype;
    
    
})();
